#pragma once
#include <ECS/ECS.h>
#include <ECS/Containers/TiledArray.h>
#include <cocos2d.h>
#include <vector>

struct LandscapeSceneNodeDef
{
	std::vector<std::string> tileSprites;
	ECS::TiledArray<int> tiles;
};

class LandscapeSceneNode : public ECS::Component
{
	mtMETA_DEC;
public:
	LandscapeSceneNode();
	virtual ~LandscapeSceneNode();

	bool initWith(LandscapeSceneNodeDef* def);

	void onStart();

	void setTile(int x, int y, int gid);
	int getTile(int x, int y) const;

	cocos2d::CCNode* getNode() const;
protected:
	std::vector<std::string> _tileSprites;
	cocos2d::CCNode* _mainNode;
	struct TileInfo
	{
		int gid;
		cocos2d::CCSprite* sprite;

		TileInfo() : gid(0), sprite(nullptr) {}
	};
	ECS::TiledArray<TileInfo> _sprites;
};